package com.order.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.order.dao.AdQuery;
import com.order.dao.AduserQuery;
import com.order.dao.bean.Ad;
import com.order.dao.bean.Aduser;

/**
 * Servlet implementation class AdServlet
 */
@WebServlet("/AdServlet")
public class AdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AdServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
		response.setContentType("text/html;charset=gbk");
    	request.setCharacterEncoding("gbk");
    	List<Ad> list = AdQuery.queryAll();
    	if(list!=null )
    	{
    		request.setAttribute("adList",list);	
    		RequestDispatcher rd=request.getRequestDispatcher("/ad.jsp");
    		rd.forward(request,response);

    	}
	}

}
